<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery-3.1.1.js"></script>
</head>
<style>
    body{
        width: 100%;
        height: 100%;
    }
    div {
        width: 200px;
        height: 200px;
        text-align: center;
        line-height: 200px;
        position: absolute;
        left: 0;
        top: 0;
        background-color: palegoldenrod;
    }
</style>

<body>
    <div>
        我是div，会跟着鼠标跑
    </div>
</body>
<script>
    $(function () {
        $(window).mousemove(function(event){
            // console.log(event.clientX)
            // console.log(event.clientY)
            let wd = $('div').innerWidth();
            let he = $('div').innerHeight();
            // console.log(wd)
            // console.log(he)
            $('div').css({
                top:event.clientY-wd/2,
                left:event.clientX-he/2            
                })
        })


    })
</script>

</html>